/**
 * Created by IntelliJ IDEA.
 * User: maticm
 * Date: Oct 11, 2003
 * Time: 2:11:10 PM
 * To change this template use Options | File Templates.
 */

package com.generalynx.common.web.navigation;

import com.generalynx.common.web.module.Module;

public class RadioItemRenderer implements IMenuItemRenderer {

    public String permittedItem(Module node) {
        return getHtml(node, false);
    }

    private String getHtml(Module node, boolean checked) {
        String id = "def_module_" + node.getId();
        String chk = checked ? " checked='checked'" : "";
        return
                "<div class='moduleRadio'>\n" +
                "<input type='radio' name='defModule' id='" + id + "'" + chk + " value='" +
                node.getId() +
                "'/>\n" +
                "<label for='" + id + "'>" +
                node.getLabel() +
                "</label>\n" +
                "</div>\n"
                ;
    }

    public String restrictedItem(Module node) {
        return null;
    }

    public String chosenItem(Module node) {
        return getHtml(node, true);
    }
}
